<?php
/*
Version 1.0
*/

session_start();

interface Contenedor {
	public function add($key, $value);
	public function set($key, $value);
	public function get($key);
	public function fetch($key);
}


class Session implements Contenedor {

	public function set($key, $value) {
		$_SESSION[$key] = $value;
	}

	public function add($key, $value) {
		if (!isset($_SESSION[$key])) {
			$_SESSION[$key] = array();
		}
		$_SESSION[$key][] = $value;
	}


//	public function set($key, $value, $replace=false) {
//		if (!isset($_SESSION[$key])) {
//			if (!$replace) {
//				$_SESSION[$key] = array();
//			}
//		}
//		if ($replace) {
//			$_SESSION[$key] = $value;
//		} else {
//			$_SESSION[$key][] = $value;
//		}
//	}

	public function get($key) {
		if (isset($_SESSION[$key])) {
			return $_SESSION[$key];
		} else {
			return null;
		}
	}

	public function fetch($key) {
		$msg = $this->get($key);
		unset ($_SESSION[$key]);
		return $msg;
	}

}

?>